import {get, put, post} from '@/utils/request'
import {AxiosPromise, Option} from "@/types/common";

/**
 * 根据 ID 获取信息
 * @param id 实体ID
 */
export const usePropItemInfoApi = (id: number) => {
    return get('/generator/v1/propItem/' + id)
}

/**
 * 新增或修改
 * @param dataForm 数据表单
 */
export const usePropItemSubmitApi = (dataForm: any) => {
    if (dataForm.id) {
        return put('/generator/v1/propItem', dataForm)
    } else {
        return post('/generator/v1/propItem', dataForm)
    }
}

/**
 * 属性组选项列表
 */
export const usePropGroupOptionsApi = (): AxiosPromise<Option[]> => {
    return get('/generator/v1/propGroup/options')
}


/**
 * 克隆属性组列表
 * @param dataForm 表单数据
 */
export const usePropGroupCloneApi = (dataForm: any): AxiosPromise<boolean> => {
    return post('/generator/v1/propGroup/clone', dataForm)
}


